//### This file created by BYACC 1.8(/Java extension  1.15)
//### Java capabilities added 7 Jan 97, Bob Jamison
//### Updated : 27 Nov 97  -- Bob Jamison, Joe Nieten
//###           01 Jan 98  -- Bob Jamison -- fixed generic semantic constructor
//###           01 Jun 99  -- Bob Jamison -- added Runnable support
//###           06 Aug 00  -- Bob Jamison -- made state variables class-global
//###           03 Jan 01  -- Bob Jamison -- improved flags, tracing
//###           16 May 01  -- Bob Jamison -- added custom stack sizing
//###           04 Mar 02  -- Yuval Oren  -- improved java performance, added options
//###           14 Mar 02  -- Tomas Hurka -- -d support, static initializer workaround
//### Please send bug reports to tom@hukatronic.cz
//### static char yysccsid[] = "@(#)yaccpar	1.8 (Berkeley) 01/20/90";






//#line 2 "gramatica.y"

package com.compiler.syntactic;

import com.compiler.lexico.token.Token;
import com.compiler.logger.Logger;

//#line 24 "Parser.java"




public class Parser
{

boolean yydebug;        //do I want debug output?
int yynerrs;            //number of errors so far
int yyerrflag;          //was there an error?
int yychar;             //the current working character

//########## MESSAGES ##########
//###############################################################
// method: debug
//###############################################################
void debug(String msg)
{
  if (yydebug)
    System.out.println(msg);
}

//########## STATE STACK ##########
final static int YYSTACKSIZE = 500;  //maximum stack size
int statestk[] = new int[YYSTACKSIZE]; //state stack
int stateptr;
int stateptrmax;                     //highest index of stackptr
int statemax;                        //state when highest index reached
//###############################################################
// methods: state stack push,pop,drop,peek
//###############################################################
final void state_push(int state)
{
  try {
		stateptr++;
		statestk[stateptr]=state;
	 }
	 catch (ArrayIndexOutOfBoundsException e) {
     int oldsize = statestk.length;
     int newsize = oldsize * 2;
     int[] newstack = new int[newsize];
     System.arraycopy(statestk,0,newstack,0,oldsize);
     statestk = newstack;
     statestk[stateptr]=state;
  }
}
final int state_pop()
{
  return statestk[stateptr--];
}
final void state_drop(int cnt)
{
  stateptr -= cnt; 
}
final int state_peek(int relative)
{
  return statestk[stateptr-relative];
}
//###############################################################
// method: init_stacks : allocate and prepare stacks
//###############################################################
final boolean init_stacks()
{
  stateptr = -1;
  val_init();
  return true;
}
//###############################################################
// method: dump_stacks : show n levels of the stacks
//###############################################################
void dump_stacks(int count)
{
int i;
  System.out.println("=index==state====value=     s:"+stateptr+"  v:"+valptr);
  for (i=0;i<count;i++)
    System.out.println(" "+i+"    "+statestk[i]+"      "+valstk[i]);
  System.out.println("======================");
}


//########## SEMANTIC VALUES ##########
//public class ParserVal is defined in ParserVal.java


String   yytext;//user variable to return contextual strings
ParserVal yyval; //used to return semantic vals from action routines
ParserVal yylval;//the 'lval' (result) I got from yylex()
ParserVal valstk[];
int valptr;
//###############################################################
// methods: value stack push,pop,drop,peek.
//###############################################################
void val_init()
{
  valstk=new ParserVal[YYSTACKSIZE];
  yyval=new ParserVal();
  yylval=new ParserVal();
  valptr=-1;
}
void val_push(ParserVal val)
{
  if (valptr>=YYSTACKSIZE)
    return;
  valstk[++valptr]=val;
}
ParserVal val_pop()
{
  if (valptr<0)
    return new ParserVal();
  return valstk[valptr--];
}
void val_drop(int cnt)
{
int ptr;
  ptr=valptr-cnt;
  if (ptr<0)
    return;
  valptr = ptr;
}
ParserVal val_peek(int relative)
{
int ptr;
  ptr=valptr-relative;
  if (ptr<0)
    return new ParserVal();
  return valstk[ptr];
}
final ParserVal dup_yyval(ParserVal val)
{
  ParserVal dup = new ParserVal();
  dup.ival = val.ival;
  dup.dval = val.dval;
  dup.sval = val.sval;
  dup.obj = val.obj;
  return dup;
}
//#### end semantic value section ####
public final static short IDENTIFICADOR=257;
public final static short UINTEGER=258;
public final static short IF=259;
public final static short THEN=260;
public final static short ELSE=261;
public final static short FOR=262;
public final static short STEP=263;
public final static short PRINT=264;
public final static short ARRAY=265;
public final static short CADENA=266;
public final static short MAYOR_IGUAL=267;
public final static short MENOR_IGUAL=268;
public final static short DISTINTO=269;
public final static short ASIGNACION=270;
public final static short NUMERO=271;
public final static short YYERRCODE=256;
final static short yylhs[] = {                           -1,
    0,    1,    1,    2,    5,    2,    7,    2,    9,    2,
   11,    2,    3,    3,    3,    3,    3,    3,    3,   12,
   12,   13,    6,    6,    6,    6,   16,    6,   17,    6,
   15,   15,    8,    8,    8,    8,    8,    8,    4,    4,
    4,    4,    4,   10,   10,   10,   18,   18,   18,   18,
   18,   14,   14,   14,   20,   20,   20,   19,   19,
};
final static short yylen[] = {                            2,
    1,    1,    2,    1,    0,    2,    0,    2,    0,    2,
    0,    3,    3,    3,    2,    3,    3,    2,    2,    1,
    3,    4,    8,   12,    7,    5,    0,    7,    0,   10,
    3,    3,   12,   11,   11,   11,    8,    2,    5,    5,
    3,    4,    2,    3,    6,    2,    1,    1,    1,    1,
    1,    3,    3,    1,    3,    3,    1,    1,    4,
};
final static short yydefred[] = {                         0,
    0,    0,    0,    0,    2,    4,    0,    0,    0,    0,
   20,   18,    0,    0,    0,   15,    0,    3,    0,    6,
    0,    8,    0,   10,    0,    0,   13,    0,   17,   16,
    0,   14,   43,    0,    0,    0,   38,    0,   46,    0,
    0,   12,   21,    0,    0,   57,    0,   41,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,   22,    0,
    0,    0,    0,    0,    0,    0,   51,   50,   47,   48,
   49,    0,    0,    0,    0,    0,    0,    0,    0,    0,
   55,   56,   39,   40,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,   59,   29,    0,    0,    0,    0,
    0,    0,    0,    0,   28,    0,   25,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,   30,    0,    0,    0,    0,    0,    0,
   36,   35,   34,    0,   24,   33,
};
final static short yydgoto[] = {                          3,
    4,    5,    6,   20,    7,   22,    8,   24,    9,   26,
   10,   13,   17,   52,   53,   86,  104,   74,   46,   47,
};
final static short yysindex[] = {                      -172,
  -50,  -52,    0, -172,    0,    0, -239, -200, -162, -146,
    0,    0,   17,   60,   -7,    0,   62,    0,  -40,    0,
   83,    0,  -35,    0,  -79,   69,    0, -117,    0,    0,
 -116,    0,    0,   84, -206, -126,    0, -123,    0, -116,
 -116,    0,    0,   51,   22,    0,   52,    0,  104,  105,
  106,   42,  -27,   89,   93,   13,   25, -116,    0, -116,
 -116, -116, -116,   95,   96,  -97,    0,    0,    0,    0,
    0, -116,  -73, -116,  -95, -120, -106,   32,   52,   52,
    0,    0,    0,    0,   45, -172,   13,   58, -172,   13,
  111,  115,  -13, -116,    0,    0, -109, -172, -108,  -91,
  -81, -143,   13, -172,    0, -107,    0,  141,  142,  143,
  -72,  -99,  -75,   65,   66,   67,  151,  -63,   72, -172,
 -172, -172,   74,    0, -172,  -98,  -89,  -87, -172,  -86,
    0,    0,    0,  -85,    0,    0,
};
final static short yyrindex[] = {                      -135,
    0,    0,    0,   41,    0,    0,    0,    0,    0,    0,
    0,    0,    1,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,  -39,    0,    0,  -30,    0,    0,    0,
    0,    0,    0,    0,    0,  139,    0,    0,    0,    0,
    0,    0,    0,   10,    0, -167,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,   12,   21,
    0,    0,    0,    0,    0, -135,  -17,   19, -135,   47,
    0,    0,    0,    0,    0,    0, -135, -135, -135,    0,
    0,    0,  140, -135,    0, -135,    0,    0,    0,    0,
    0, -135,   28,   37,    0,    0,    0,    0,    0, -135,
 -135, -135,    0,    0, -135, -135, -135, -135, -135, -135,
    0,    0,    0, -135,    0,    0,
};
final static short yygindex[] = {                         0,
  218,   97,    0,    0,    0,    0,    0,    0,    0,  162,
    0,    0,    0,   38,  125,    0,    0,  150,   54,   78,
};
final static int YYTABLESIZE=347;
static short yytable[];
static { yytable();}
static void yytable(){
yytable = new short[]{                         35,
   19,   58,   58,   58,   38,   58,   16,   58,   12,   42,
   54,   41,   54,   73,   54,  105,  107,  113,   26,   58,
   58,   58,   58,   32,   19,  118,  131,   23,   54,   54,
   54,   54,   69,   71,   70,  132,   37,  133,  135,  136,
    1,   32,   32,   32,   32,  102,   69,   71,   70,   89,
   44,   30,   52,   58,   52,   60,   52,   61,   21,   49,
   28,   53,   54,   53,   60,   53,   61,   60,   45,   61,
   52,   52,   52,   52,   60,   27,   61,   56,   57,   53,
   53,   53,   53,   31,   60,    1,   61,   31,   50,   27,
   27,   27,    2,   62,   27,   78,   27,   27,   63,   23,
   18,   69,   71,   70,   52,   31,   31,   31,   31,   87,
   25,   90,  110,   53,   59,   81,   82,   77,   29,  111,
   32,   11,   36,    7,   95,   19,    9,   42,    5,   51,
   44,  103,   54,   25,   42,   92,   44,   79,   80,   43,
   44,   58,   48,   26,   64,   65,   66,   75,    1,    1,
    1,   76,   23,   83,   84,    2,    2,    2,    1,    1,
   91,   37,   85,   94,  108,    2,    2,   96,    1,  100,
    1,    1,    1,  101,  109,    2,   39,    2,    2,    2,
   98,  114,  115,  116,  117,  119,   88,  120,  121,  122,
   40,  123,  124,   18,  125,   18,  129,   44,   45,   55,
   93,   72,   18,   14,   15,    0,   11,    0,   18,    0,
    0,    0,    0,    0,    0,   33,    0,    0,    0,    0,
   37,    0,   18,   18,   18,   34,   18,   58,   58,    0,
   18,    0,    0,    0,    0,    0,   54,   54,    0,   67,
   68,    0,    0,    0,    0,    0,    0,    0,    0,   32,
   32,    0,    0,   67,   68,    0,    0,   19,   19,   19,
    0,    0,   19,    0,   19,   19,   42,   42,   42,    0,
    0,   42,    0,   42,   42,   26,   26,   26,   52,   52,
   26,    0,   26,   26,   23,   23,   23,   53,   53,   23,
    0,   23,   23,   37,   37,   37,    0,   11,   37,    7,
   37,   37,    9,   97,    5,    0,   99,    0,   67,   68,
    0,    0,    0,   31,   31,  106,    0,    0,    0,    0,
    0,  112,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,  126,  127,  128,
    0,    0,  130,    0,    0,    0,  134,
};
}
static short yycheck[];
static { yycheck(); }
static void yycheck() {
yycheck = new short[] {                         40,
    0,   41,   42,   43,   40,   45,   59,   47,   59,    0,
   41,   91,   43,   41,   45,  125,  125,  125,    0,   59,
   60,   61,   62,   41,  264,  125,  125,    0,   59,   60,
   61,   62,   60,   61,   62,  125,    0,  125,  125,  125,
    0,   59,   60,   61,   62,   59,   60,   61,   62,  123,
  257,   59,   41,   93,   43,   43,   45,   45,  259,  266,
   44,   41,   93,   43,   43,   45,   45,   43,   31,   45,
   59,   60,   61,   62,   43,   59,   45,   40,   41,   59,
   60,   61,   62,   91,   43,  258,   45,   41,   35,  257,
  258,  259,  265,   42,  262,   58,  264,  265,   47,  262,
    4,   60,   61,   62,   93,   59,   60,   61,   62,   72,
  257,   74,  256,   93,   93,   62,   63,   93,   59,  263,
   59,  257,   40,  259,   93,  125,  262,   59,  264,  256,
  257,   94,  256,  257,  125,  256,  257,   60,   61,  257,
  257,   91,   59,  125,   41,   41,   41,   59,  258,  258,
  258,   59,  125,   59,   59,  265,  265,  265,  258,  258,
  256,  125,  260,  270,  256,  265,  265,  123,  258,   59,
  258,  258,  258,   59,  256,  265,  256,  265,  265,  265,
  123,   41,   41,   41,  257,  261,  260,  123,  123,  123,
  270,   41,  256,   97,  123,   99,  123,   59,   59,   38,
   76,   52,  106,  256,  257,   -1,  257,   -1,  112,   -1,
   -1,   -1,   -1,   -1,   -1,  256,   -1,   -1,   -1,   -1,
  256,   -1,  126,  127,  128,  266,  130,  267,  268,   -1,
  134,   -1,   -1,   -1,   -1,   -1,  267,  268,   -1,  267,
  268,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,  267,
  268,   -1,   -1,  267,  268,   -1,   -1,  257,  258,  259,
   -1,   -1,  262,   -1,  264,  265,  257,  258,  259,   -1,
   -1,  262,   -1,  264,  265,  257,  258,  259,  267,  268,
  262,   -1,  264,  265,  257,  258,  259,  267,  268,  262,
   -1,  264,  265,  257,  258,  259,   -1,  257,  262,  259,
  264,  265,  262,   86,  264,   -1,   89,   -1,  267,  268,
   -1,   -1,   -1,  267,  268,   98,   -1,   -1,   -1,   -1,
   -1,  104,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
   -1,   -1,   -1,   -1,   -1,   -1,   -1,  120,  121,  122,
   -1,   -1,  125,   -1,   -1,   -1,  129,
};
}
final static short YYFINAL=3;
final static short YYMAXTOKEN=271;
final static String yyname[] = {
"end-of-file",null,null,null,null,null,null,null,null,null,null,null,null,null,
null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,
null,null,null,null,null,null,null,null,null,null,"'('","')'","'*'","'+'","','",
"'-'",null,"'/'",null,null,null,null,null,null,null,null,null,null,null,"';'",
"'<'","'='","'>'",null,null,null,null,null,null,null,null,null,null,null,null,
null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,
"'['",null,"']'",null,null,null,null,null,null,null,null,null,null,null,null,
null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,
null,"'{'",null,"'}'",null,null,null,null,null,null,null,null,null,null,null,
null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,
null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,
null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,
null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,
null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,
null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,
null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,
null,null,null,null,null,null,null,null,"IDENTIFICADOR","UINTEGER","IF","THEN",
"ELSE","FOR","STEP","PRINT","ARRAY","CADENA","MAYOR_IGUAL","MENOR_IGUAL",
"DISTINTO","ASIGNACION","NUMERO",
};
final static String yyrule[] = {
"$accept : programa",
"programa : sentencias",
"sentencias : sentencia",
"sentencias : sentencias sentencia",
"sentencia : declaracion",
"$$1 :",
"sentencia : $$1 impresion",
"$$2 :",
"sentencia : $$2 seleccion",
"$$3 :",
"sentencia : $$3 bucle",
"$$4 :",
"sentencia : $$4 asignacion ';'",
"declaracion : UINTEGER variables ';'",
"declaracion : ARRAY arreglo ';'",
"declaracion : ARRAY ';'",
"declaracion : ARRAY IDENTIFICADOR ';'",
"declaracion : ARRAY error ';'",
"declaracion : UINTEGER ';'",
"declaracion : UINTEGER variables",
"variables : IDENTIFICADOR",
"variables : variables ',' IDENTIFICADOR",
"arreglo : IDENTIFICADOR '[' expresion ']'",
"seleccion : IF '(' condicion ')' THEN '{' sentencias '}'",
"seleccion : IF '(' condicion ')' THEN '{' sentencias '}' ELSE '{' sentencias '}'",
"seleccion : IF '(' condicion ')' '{' sentencias '}'",
"seleccion : IF '(' condicion ')' THEN",
"$$5 :",
"seleccion : IF '(' error ')' $$5 sentencias '}'",
"$$6 :",
"seleccion : IF '(' error ')' THEN '{' $$6 sentencias '}' error",
"condicion : condicion comparador expresion",
"condicion : expresion comparador expresion",
"bucle : FOR '(' asignacion ';' condicion ';' STEP IDENTIFICADOR ')' '{' sentencias '}'",
"bucle : FOR '(' asignacion ';' condicion ';' error ')' '{' sentencias '}'",
"bucle : FOR '(' asignacion ';' error ';' error ')' '{' sentencias '}'",
"bucle : FOR '(' error ';' error ';' error ')' '{' sentencias '}'",
"bucle : FOR '(' error ';' error ';' error ')'",
"bucle : FOR error",
"impresion : PRINT '(' CADENA ')' ';'",
"impresion : PRINT '(' argumento ')' ';'",
"impresion : PRINT CADENA ';'",
"impresion : PRINT '(' CADENA ')'",
"impresion : PRINT error",
"asignacion : IDENTIFICADOR ASIGNACION expresion",
"asignacion : IDENTIFICADOR '[' expresion ']' ASIGNACION expresion",
"asignacion : IDENTIFICADOR error",
"comparador : '<'",
"comparador : '>'",
"comparador : '='",
"comparador : MENOR_IGUAL",
"comparador : MAYOR_IGUAL",
"expresion : expresion '+' termino",
"expresion : expresion '-' termino",
"expresion : termino",
"termino : termino '*' argumento",
"termino : termino '/' argumento",
"termino : argumento",
"argumento : IDENTIFICADOR",
"argumento : IDENTIFICADOR '[' expresion ']'",
};

//#line 102 "gramatica.y"
private com.compiler.logger.TokenPipe tokenPipe;
private Token token;

public Parser(com.compiler.logger.TokenPipe tokenPipe) {
	this.tokenPipe = tokenPipe;
}

private int yylex(){
	int yyl_return = -1;
	while (!this.tokenPipe.isEmpty()) {
		token = this.tokenPipe.getToken();
		yyl_return = token.yylex();
		yylval = token.getParserVal();
		return yyl_return;
	}
	return 0;
}

private void yyerror(String stack_underflow_aborting) {
}
//#line 371 "Parser.java"
//###############################################################
// method: yylexdebug : check lexer state
//###############################################################
void yylexdebug(int state,int ch)
{
String s=null;
  if (ch < 0) ch=0;
  if (ch <= YYMAXTOKEN) //check index bounds
     s = yyname[ch];    //now get it
  if (s==null)
    s = "illegal-symbol";
  debug("state "+state+", reading "+ch+" ("+s+")");
}





//The following are now global, to aid in error reporting
int yyn;       //next next thing to do
int yym;       //
int yystate;   //current parsing state from state table
String yys;    //current token string


//###############################################################
// method: yyparse : parse input and execute indicated items
//###############################################################
int yyparse()
{
boolean doaction;
  init_stacks();
  yynerrs = 0;
  yyerrflag = 0;
  yychar = -1;          //impossible char forces a read
  yystate=0;            //initial state
  state_push(yystate);  //save it
  val_push(yylval);     //save empty value
  while (true) //until parsing is done, either correctly, or w/error
    {
    doaction=true;
    if (yydebug) debug("loop"); 
    //#### NEXT ACTION (from reduction table)
    for (yyn=yydefred[yystate];yyn==0;yyn=yydefred[yystate])
      {
      if (yydebug) debug("yyn:"+yyn+"  state:"+yystate+"  yychar:"+yychar);
      if (yychar < 0)      //we want a char?
        {
        yychar = yylex();  //get next token
        if (yydebug) debug(" next yychar:"+yychar);
        //#### ERROR CHECK ####
        if (yychar < 0)    //it it didn't work/error
          {
          yychar = 0;      //change it to default string (no -1!)
          if (yydebug)
            yylexdebug(yystate,yychar);
          }
        }//yychar<0
      yyn = yysindex[yystate];  //get amount to shift by (shift index)
      if ((yyn != 0) && (yyn += yychar) >= 0 &&
          yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
        {
        if (yydebug)
          debug("state "+yystate+", shifting to state "+yytable[yyn]);
        //#### NEXT STATE ####
        yystate = yytable[yyn];//we are in a new state
        state_push(yystate);   //save it
        val_push(yylval);      //push our lval as the input for next rule
        yychar = -1;           //since we have 'eaten' a token, say we need another
        if (yyerrflag > 0)     //have we recovered an error?
           --yyerrflag;        //give ourselves credit
        doaction=false;        //but don't process yet
        break;   //quit the yyn=0 loop
        }

    yyn = yyrindex[yystate];  //reduce
    if ((yyn !=0 ) && (yyn += yychar) >= 0 &&
            yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
      {   //we reduced!
      if (yydebug) debug("reduce");
      yyn = yytable[yyn];
      doaction=true; //get ready to execute
      break;         //drop down to actions
      }
    else //ERROR RECOVERY
      {
      if (yyerrflag==0)
        {
        yyerror("syntax error");
        yynerrs++;
        }
      if (yyerrflag < 3) //low error count?
        {
        yyerrflag = 3;
        while (true)   //do until break
          {
          if (stateptr<0)   //check for under & overflow here
            {
            yyerror("stack underflow. aborting...");  //note lower case 's'
            return 1;
            }
          yyn = yysindex[state_peek(0)];
          if ((yyn != 0) && (yyn += YYERRCODE) >= 0 &&
                    yyn <= YYTABLESIZE && yycheck[yyn] == YYERRCODE)
            {
            if (yydebug)
              debug("state "+state_peek(0)+", error recovery shifting to state "+yytable[yyn]+" ");
            yystate = yytable[yyn];
            state_push(yystate);
            val_push(yylval);
            doaction=false;
            break;
            }
          else
            {
            if (yydebug)
              debug("error recovery discarding state "+state_peek(0)+" ");
            if (stateptr<0)   //check for under & overflow here
              {
              yyerror("Stack underflow. aborting...");  //capital 'S'
              return 1;
              }
            state_pop();
            val_pop();
            }
          }
        }
      else            //discard this token
        {
        if (yychar == 0)
          return 1; //yyabort
        if (yydebug)
          {
          yys = null;
          if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
          if (yys == null) yys = "illegal-symbol";
          debug("state "+yystate+", error recovery discards token "+yychar+" ("+yys+")");
          }
        yychar = -1;  //read another
        }
      }//end error recovery
    }//yyn=0 loop
    if (!doaction)   //any reason not to proceed?
      continue;      //skip action
    yym = yylen[yyn];          //get count of terminals on rhs
    if (yydebug)
      debug("state "+yystate+", reducing "+yym+" by rule "+yyn+" ("+yyrule[yyn]+")");
    if (yym>0)                 //if count of rhs not 'nil'
      yyval = val_peek(yym-1); //get current semantic value
    yyval = dup_yyval(yyval); //duplicate yyval if ParserVal is used as semantic value
    switch(yyn)
      {
//########## USER-SUPPLIED ACTIONS ##########
case 5:
//#line 24 "gramatica.y"
{System.out.println("Linea #"+token.getLine()+" --> sentencia PRINT");}
break;
case 7:
//#line 25 "gramatica.y"
{System.out.println("Linea #"+token.getLine()+" --> sentencia IF");}
break;
case 9:
//#line 26 "gramatica.y"
{System.out.println("Linea #"+token.getLine()+" --> sentencia FOR");}
break;
case 11:
//#line 27 "gramatica.y"
{System.out.println("Linea #"+token.getLine()+" --> asignacion");}
break;
case 13:
//#line 30 "gramatica.y"
{System.out.println("Linea #"+token.getLine()+" --> declaracion {UINTEGER}");}
break;
case 14:
//#line 31 "gramatica.y"
{System.out.println("Linea #"+token.getLine()+" --> declaracion {ARRAY}");}
break;
case 15:
//#line 32 "gramatica.y"
{Logger.getInstance().log("SINTACTICO", Logger.ERRORLevel,"Linea #"+token.getLine()+" --> declaracion de arreglo","SINTACTICO");}
break;
case 16:
//#line 33 "gramatica.y"
{Logger.getInstance().log("SINTACTICO", Logger.ERRORLevel,"Linea #"+token.getLine()+" --> declaracion de arreglo","SINTACTICO");}
break;
case 17:
//#line 34 "gramatica.y"
{Logger.getInstance().log("SINTACTICO", Logger.ERRORLevel,"Linea #"+token.getLine()+" --> declaracion de arreglo","SINTACTICO");}
break;
case 18:
//#line 35 "gramatica.y"
{Logger.getInstance().log("SINTACTICO", Logger.ERRORLevel,"Linea #"+token.getLine()+" --> declaracion de variable","SINTACTICO");}
break;
case 19:
//#line 36 "gramatica.y"
{Logger.getInstance().log("SINTACTICO", Logger.ERRORLevel,"Linea #"+token.getLine()+" --> falta ;","SINTACTICO");}
break;
case 25:
//#line 48 "gramatica.y"
{Logger.getInstance().log("SINTACTICO", Logger.ERRORLevel,"Linea #"+token.getLine()+" --> falta THEN","SINTACTICO");}
break;
case 26:
//#line 49 "gramatica.y"
{Logger.getInstance().log("SINTACTICO", Logger.ERRORLevel,"Linea #"+token.getLine()+" --> falta {SENTENCIAS}","SINTACTICO");}
break;
case 27:
//#line 50 "gramatica.y"
{Logger.getInstance().log("SINTACTICO", Logger.ERRORLevel,"Linea #"+token.getLine()+" --> IF mal formddado","SINTACTICO");}
break;
case 29:
//#line 51 "gramatica.y"
{Logger.getInstance().log("SINTACTICO", Logger.ERRORLevel,"Linea #"+token.getLine()+" --> IF mal formado","SINTACTICO");}
break;
case 34:
//#line 59 "gramatica.y"
{Logger.getInstance().log("SINTACTICO", Logger.ERRORLevel,"Linea #"+token.getLine()+" -->  FOR mal formado","SINTACTICO");}
break;
case 35:
//#line 60 "gramatica.y"
{Logger.getInstance().log("SINTACTICO", Logger.ERRORLevel,"Linea #"+token.getLine()+" --> FOR mal formado","SINTACTICO");}
break;
case 36:
//#line 61 "gramatica.y"
{Logger.getInstance().log("SINTACTICO", Logger.ERRORLevel,"Linea #"+token.getLine()+" --> FOR mal formado","SINTACTICO");}
break;
case 37:
//#line 62 "gramatica.y"
{Logger.getInstance().log("SINTACTICO", Logger.ERRORLevel,"Linea #"+token.getLine()+" --> FOR mal formado, falta bloque {}","SINTACTICO");}
break;
case 38:
//#line 63 "gramatica.y"
{Logger.getInstance().log("SINTACTICO", Logger.ERRORLevel,"Linea #"+token.getLine()+" -->  FOR mal formado","SINTACTICO");}
break;
case 41:
//#line 68 "gramatica.y"
{Logger.getInstance().log("SINTACTICO", Logger.ERRORLevel,"Linea #"+token.getLine()+" --> faltan parentesis","SINTACTICO");}
break;
case 42:
//#line 69 "gramatica.y"
{Logger.getInstance().log("SINTACTICO", Logger.ERRORLevel,"Linea #"+token.getLine()+" --> faltan ;","SINTACTICO");}
break;
case 43:
//#line 70 "gramatica.y"
{Logger.getInstance().log("SINTACTICO", Logger.ERRORLevel,"Linea #"+token.getLine()+" --> PRINT mal formado ","SINTACTICO");}
break;
case 46:
//#line 76 "gramatica.y"
{Logger.getInstance().log("SINTACTICO", Logger.ERRORLevel,"Linea #"+token.getLine()+" --> asignacion incompleta, falta constante","SINTACTICO");}
break;
case 52:
//#line 86 "gramatica.y"
{}
break;
//#line 620 "Parser.java"
//########## END OF USER-SUPPLIED ACTIONS ##########
    }//switch
    //#### Now let's reduce... ####
    if (yydebug) debug("reduce");
    state_drop(yym);             //we just reduced yylen states
    yystate = state_peek(0);     //get new state
    val_drop(yym);               //corresponding value drop
    yym = yylhs[yyn];            //select next TERMINAL(on lhs)
    if (yystate == 0 && yym == 0)//done? 'rest' state and at first TERMINAL
      {
      if (yydebug) debug("After reduction, shifting from state 0 to state "+YYFINAL+"");
      yystate = YYFINAL;         //explicitly say we're done
      state_push(YYFINAL);       //and save it
      val_push(yyval);           //also save the semantic value of parsing
      if (yychar < 0)            //we want another character?
        {
        yychar = yylex();        //get next character
        if (yychar<0) yychar=0;  //clean, if necessary
        if (yydebug)
          yylexdebug(yystate,yychar);
        }
      if (yychar == 0)          //Good exit (if lex returns 0 ;-)
         break;                 //quit the loop--all DONE
      }//if yystate
    else                        //else not done yet
      {                         //get next state and push, for next yydefred[]
      yyn = yygindex[yym];      //find out where to go
      if ((yyn != 0) && (yyn += yystate) >= 0 &&
            yyn <= YYTABLESIZE && yycheck[yyn] == yystate)
        yystate = yytable[yyn]; //get new state
      else
        yystate = yydgoto[yym]; //else go to new defred
      if (yydebug) debug("after reduction, shifting from state "+state_peek(0)+" to state "+yystate+"");
      state_push(yystate);     //going again, so push state & val...
      val_push(yyval);         //for next action
      }
    }//main loop
  return 0;//yyaccept!!
}
//## end of method parse() ######################################



//## run() --- for Thread #######################################
/**
 * A default run method, used for operating this parser
 * object in the background.  It is intended for extending Thread
 * or implementing Runnable.  Turn off with -Jnorun .
 */
public void run()
{
  yyparse();
}
//## end of method run() ########################################



//## Constructors ###############################################
/**
 * Default constructor.  Turn off with -Jnoconstruct .

 */
public Parser()
{
  //nothing to do
}


/**
 * Create a parser, setting the debug to true or false.
 * @param debugMe true for debugging, false for no debug.
 */
public Parser(boolean debugMe)
{
  yydebug=debugMe;
}
//###############################################################



}
//################### END OF CLASS ##############################
